package com.dp.springsourcecodeanalysis.web;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.dp.springsourcecodeanalysis.dto.ResponseDTO;
import com.dp.springsourcecodeanalysis.exceptions.AppException;

/**
 * Created by IntelliJ IDEA
 *
 * @author shala/沙拉
 * @date 2022/1/20 15:31
 */
@RestController
@RequestMapping("/exception")
public class ExceptionController {

    @GetMapping("/throw")
    public ResponseDTO<String> throwException() throws Exception {
        System.out.println("ceshi");
        throw new Exception("出错了，系统异常");
    }

    @GetMapping("/throw_app")
    public ResponseDTO<String> throwAppException() throws Exception {
        throw AppException.create("操作失败，业务异常");
    }

}
